home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 June: Reference Library / Dev.CD Jun 95 / Dev.CD Jun 95.toast / What's New? / New System Software Extensions / QuickDraw 3D ß / Programming / Interfaces / QD3DMath.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-04  |  22.9 KB  |  880 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DMath.h                                                 **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **                                                                          **
  7.  **     Purpose:     Math & matrix routines and definitions.                     **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1992-1994 Apple Computer, Inc.  All rights reserved.     **
  11.  **                                                                          **
  12.  **                                                                          ** 
  13.  *****************************************************************************/
  14. #ifndef QD3DMath_h
  15. #define QD3DMath_h
  16.  
  17. #if PRAGMA_ONCE
  18.     #pragma once
  19. #endif
  20.  
  21. #include <math.h>
  22. #include <float.h>
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif    /* __cplusplus */
  27.  
  28. /******************************************************************************
  29.  **                                                                             **
  30.  **                                                                             **
  31.  **                            Constant Definitions                             **
  32.  **                                                                             **
  33.  **                                                                             **
  34.  *****************************************************************************/
  35. /*
  36.  *  Real zero definition
  37.  */
  38. #ifdef FLT_EPSILON
  39. #    define kQ3RealZero                (FLT_EPSILON)
  40. #else
  41. #    define kQ3RealZero                ((float)1.19209290e-07)            
  42. #endif  /*  FLT_EPSILON  */
  43.  
  44. #ifdef FLT_MAX
  45. #    define    kQ3MaxFloat                (FLT_MAX)
  46. #else
  47. #    define    kQ3MaxFloat                ((float)3.40282347e+38)
  48. #endif  /*  FLT_MAX  */
  49.  
  50. /*
  51.  *  Values of PI
  52.  */
  53. #define kQ3Pi                     (3.1415926535898)
  54. #define kQ32Pi                     (2.0 * kQ3Pi)
  55.  
  56.         
  57. /******************************************************************************
  58.  **                                                                             **
  59.  **                            Point and Vector Creation                         **
  60.  **                                                                             **
  61.  *****************************************************************************/
  62.  
  63. EXPORT TQ3Point2D *Q3Point2D_Set(
  64.     TQ3Point2D            *point2D,
  65.     float                x, 
  66.     float                y);
  67.  
  68. EXPORT TQ3Param2D *Q3Param2D_Set(
  69.     TQ3Param2D            *param2D,
  70.     float                u, 
  71.     float                v);
  72.  
  73. EXPORT TQ3Point3D *Q3Point3D_Set(
  74.     TQ3Point3D            *point3D,
  75.     float                x, 
  76.     float                y, 
  77.     float                z);
  78.  
  79. EXPORT TQ3RationalPoint3D *Q3RationalPoint3D_Set(
  80.     TQ3RationalPoint3D    *point3D,
  81.     float                x, 
  82.     float                y, 
  83.     float                w);
  84.     
  85. EXPORT TQ3RationalPoint4D *Q3RationalPoint4D_Set(
  86.     TQ3RationalPoint4D    *point4D,
  87.     float                x,
  88.     float                y,
  89.     float                z, 
  90.     float                w);
  91.     
  92. EXPORT TQ3Vector2D *Q3Vector2D_Set(
  93.     TQ3Vector2D            *vector2D,
  94.     float                x, 
  95.     float                y);
  96.  
  97. EXPORT TQ3Vector3D *Q3Vector3D_Set(
  98.     TQ3Vector3D            *vector3D,
  99.     float                x, 
  100.     float                y, 
  101.     float                z);
  102.  
  103. EXPORT TQ3PolarPoint *Q3PolarPoint_Set(
  104.     TQ3PolarPoint        *polarPoint,
  105.     float                r,
  106.     float                theta);
  107.  
  108. EXPORT TQ3SphericalPoint *Q3SphericalPoint_Set(
  109.     TQ3SphericalPoint    *sphericalPoint,
  110.     float                rho,
  111.     float                theta,
  112.     float                phi);
  113.     
  114.     
  115. /******************************************************************************
  116.  **                                                                             **
  117.  **                    Point and Vector Dimension Conversion                     **
  118.  **                                                                             **
  119.  *****************************************************************************/
  120.  
  121. EXPORT TQ3Point3D *Q3Point2D_To3D(
  122.     const TQ3Point2D            *point2D,
  123.     TQ3Point3D                    *result);
  124.  
  125. EXPORT TQ3Point2D *Q3RationalPoint3D_To2D(
  126.     const TQ3RationalPoint3D    *point3D,
  127.     TQ3Point2D                    *result);
  128.     
  129. EXPORT TQ3RationalPoint4D *Q3Point3D_To4D(
  130.     const TQ3Point3D            *point3D,
  131.     TQ3RationalPoint4D            *result);
  132.  
  133. EXPORT TQ3Point3D *Q3RationalPoint4D_To3D(
  134.     const TQ3RationalPoint4D    *point4D,
  135.     TQ3Point3D                    *result);
  136.  
  137. EXPORT TQ3Vector3D *Q3Vector2D_To3D(
  138.     const TQ3Vector2D            *vector2D,
  139.     TQ3Vector3D                    *result);
  140.     
  141. EXPORT TQ3Vector2D *Q3Vector3D_To2D(
  142.     const TQ3Vector3D            *vector3D,
  143.     TQ3Vector2D                    *result);
  144.  
  145.     
  146. /******************************************************************************
  147.  **                                                                             **
  148.  **                            Point Subtraction                                 **
  149.  **                                                                             **
  150.  *****************************************************************************/
  151.  
  152. EXPORT TQ3Vector2D *Q3Point2D_Subtract(
  153.     const TQ3Point2D            *p1, 
  154.     const TQ3Point2D            *p2,
  155.     TQ3Vector2D                *result);
  156.  
  157. EXPORT TQ3Vector2D *Q3Param2D_Subtract(
  158.     const TQ3Param2D            *p1, 
  159.     const TQ3Param2D            *p2,
  160.     TQ3Vector2D                *result);
  161.  
  162. EXPORT TQ3Vector3D *Q3Point3D_Subtract(
  163.     const TQ3Point3D            *p1, 
  164.     const TQ3Point3D            *p2,
  165.     TQ3Vector3D                *result);
  166.     
  167.     
  168. /******************************************************************************
  169.  **                                                                             **
  170.  **                            Point Distance                                     **
  171.  **                                                                             **
  172.  *****************************************************************************/
  173.     
  174. EXPORT float Q3Point2D_Distance(
  175.     const TQ3Point2D                *p1, 
  176.     const TQ3Point2D                *p2);
  177.  
  178. EXPORT float Q3Point2D_DistanceSquared(
  179.     const TQ3Point2D                *p1, 
  180.     const TQ3Point2D                *p2);
  181.  
  182.  
  183. EXPORT float Q3Param2D_Distance(
  184.     const TQ3Param2D                *p1, 
  185.     const TQ3Param2D                *p2);
  186.  
  187. EXPORT float Q3Param2D_DistanceSquared(
  188.     const TQ3Param2D                *p1, 
  189.     const TQ3Param2D                *p2);
  190.     
  191.     
  192. EXPORT float Q3RationalPoint3D_Distance(
  193.     const TQ3RationalPoint3D        *p1, 
  194.     const TQ3RationalPoint3D        *p2);
  195.     
  196. EXPORT float Q3RationalPoint3D_DistanceSquared(
  197.     const TQ3RationalPoint3D        *p1, 
  198.     const TQ3RationalPoint3D        *p2);
  199.  
  200.  
  201. EXPORT float Q3Point3D_Distance(
  202.     const TQ3Point3D                *p1, 
  203.     const TQ3Point3D                *p2);
  204.  
  205. EXPORT float Q3Point3D_DistanceSquared(
  206.     const TQ3Point3D                *p1, 
  207.     const TQ3Point3D                *p2);
  208.  
  209.  
  210. EXPORT float Q3RationalPoint4D_Distance(
  211.     const TQ3RationalPoint4D        *p1, 
  212.     const TQ3RationalPoint4D        *p2);
  213.  
  214. EXPORT float Q3RationalPoint4D_DistanceSquared(
  215.     const TQ3RationalPoint4D        *p1, 
  216.     const TQ3RationalPoint4D        *p2);
  217.  
  218.  
  219. /******************************************************************************
  220.  **                                                                             **
  221.  **                            Point Relative Ratio                             **
  222.  **                                                                             **
  223.  *****************************************************************************/
  224.  
  225. EXPORT TQ3Point2D *Q3Point2D_RRatio(
  226.     const TQ3Point2D                *p1,
  227.     const TQ3Point2D                *p2,
  228.     float                        r1,
  229.     float                        r2,
  230.     TQ3Point2D                    *result);
  231.  
  232. EXPORT TQ3Param2D *Q3Param2D_RRatio(
  233.     const TQ3Param2D                *p1,
  234.     const TQ3Param2D                *p2,
  235.     float                        r1,
  236.     float                        r2,
  237.     TQ3Param2D                    *result);
  238.  
  239. EXPORT TQ3Point3D *Q3Point3D_RRatio(
  240.     const TQ3Point3D                *p1,
  241.     const TQ3Point3D                *p2,
  242.     float                        r1,
  243.     float                        r2,
  244.     TQ3Point3D                    *result);
  245.  
  246. EXPORT TQ3RationalPoint4D *Q3RationalPoint4D_RRatio(
  247.     const TQ3RationalPoint4D        *p1,
  248.     const TQ3RationalPoint4D        *p2,
  249.     float                        r1,
  250.     float                        r2,
  251.     TQ3RationalPoint4D            *result);
  252.                         
  253.                         
  254. /******************************************************************************
  255.  **                                                                             **
  256.  **                    Point / Vector Addition    & Subtraction                     **
  257.  **                                                                             **
  258.  *****************************************************************************/
  259.  
  260. EXPORT TQ3Point2D *Q3Point2D_Vector2D_Add(
  261.     const TQ3Point2D        *point2D, 
  262.     const TQ3Vector2D    *vector2D,
  263.     TQ3Point2D            *result);
  264.  
  265. EXPORT TQ3Param2D *Q3Param2D_Vector2D_Add(
  266.     const TQ3Param2D        *param2D, 
  267.     const TQ3Vector2D    *vector2D,
  268.     TQ3Param2D            *result);
  269.  
  270. EXPORT TQ3Point3D *Q3Point3D_Vector3D_Add(
  271.     const TQ3Point3D        *point3D, 
  272.     const TQ3Vector3D    *vector3D,
  273.     TQ3Point3D            *result);
  274.  
  275. EXPORT TQ3Point2D *Q3Point2D_Vector2D_Subtract(
  276.     const TQ3Point2D        *point2D, 
  277.     const TQ3Vector2D    *vector2D,
  278.     TQ3Point2D            *result);
  279.  
  280. EXPORT TQ3Param2D *Q3Param2D_Vector2D_Subtract(
  281.     const TQ3Param2D        *param2D, 
  282.     const TQ3Vector2D    *vector2D,
  283.     TQ3Param2D            *result);
  284.  
  285. EXPORT TQ3Point3D *Q3Point3D_Vector3D_Subtract(
  286.     const TQ3Point3D        *point3D, 
  287.     const TQ3Vector3D    *vector3D,
  288.     TQ3Point3D            *result);
  289.  
  290.  
  291. /******************************************************************************
  292.  **                                                                             **
  293.  **                                Vector Scale                                 **
  294.  **                                                                             **
  295.  *****************************************************************************/
  296.                         
  297. EXPORT TQ3Vector2D *Q3Vector2D_Scale(
  298.     const TQ3Vector2D    *vector2D, 
  299.     float                scalar,
  300.     TQ3Vector2D            *result);
  301.  
  302. EXPORT TQ3Vector3D *Q3Vector3D_Scale(
  303.     const TQ3Vector3D    *vector3D, 
  304.     float                scalar,
  305.     TQ3Vector3D            *result);
  306.  
  307.     
  308. /******************************************************************************
  309.  **                                                                             **
  310.  **                                Vector Length                                 **
  311.  **                                                                             **
  312.  *****************************************************************************/
  313.  
  314. EXPORT float Q3Vector2D_Length(
  315.     const TQ3Vector2D     *vector2D);
  316.  
  317. EXPORT float Q3Vector3D_Length(
  318.     const TQ3Vector3D    *vector3D);
  319.  
  320.     
  321. /******************************************************************************
  322.  **                                                                             **
  323.  **                                Vector Normalize                             **
  324.  **                                                                             **
  325.  *****************************************************************************/
  326.  
  327. EXPORT TQ3Vector2D *Q3Vector2D_Normalize(
  328.     const TQ3Vector2D    *vector2D,
  329.     TQ3Vector2D            *result);
  330.  
  331. EXPORT TQ3Vector3D *Q3Vector3D_Normalize(
  332.     const TQ3Vector3D    *vector3D,
  333.     TQ3Vector3D            *result);
  334.  
  335.  
  336. /******************************************************************************
  337.  **                                                                             **
  338.  **                    Vector/Vector Addition and Subtraction                     **
  339.  **                                                                             **
  340.  *****************************************************************************/
  341.  
  342. EXPORT TQ3Vector2D *Q3Vector2D_Add(
  343.     const TQ3Vector2D    *v1, 
  344.     const TQ3Vector2D    *v2,
  345.     TQ3Vector2D            *result);
  346.  
  347. EXPORT TQ3Vector3D *Q3Vector3D_Add(
  348.     const TQ3Vector3D    *v1, 
  349.     const TQ3Vector3D    *v2, 
  350.     TQ3Vector3D            *result);
  351.  
  352.  
  353. EXPORT TQ3Vector2D *Q3Vector2D_Subtract(
  354.     const TQ3Vector2D    *v1, 
  355.     const TQ3Vector2D    *v2, 
  356.     TQ3Vector2D            *result);
  357.  
  358. EXPORT TQ3Vector3D *Q3Vector3D_Subtract(
  359.     const TQ3Vector3D    *v1, 
  360.     const TQ3Vector3D    *v2,
  361.     TQ3Vector3D            *result);
  362.  
  363.  
  364. /******************************************************************************
  365.  **                                                                             **
  366.  **                                Cross Product                                 **
  367.  **                                                                             **
  368.  *****************************************************************************/
  369.  
  370. EXPORT float Q3Vector2D_Cross(
  371.     const TQ3Vector2D    *v1, 
  372.     const TQ3Vector2D    *v2);
  373.  
  374. EXPORT TQ3Vector3D *Q3Vector3D_Cross(
  375.     const TQ3Vector3D    *v1, 
  376.     const TQ3Vector3D    *v2,
  377.     TQ3Vector3D            *result);
  378.     
  379. EXPORT TQ3Vector3D *Q3Point3D_CrossProductTri(
  380.     const TQ3Point3D     *point1, 
  381.     const TQ3Point3D     *point2, 
  382.     const TQ3Point3D     *point3, 
  383.     TQ3Vector3D             *crossVector);
  384.  
  385.  
  386. /******************************************************************************
  387.  **                                                                             **
  388.  **                                Dot Product                                     **
  389.  **                                                                             **
  390.  *****************************************************************************/
  391.  
  392. EXPORT float Q3Vector2D_Dot(
  393.     const TQ3Vector2D    *v1, 
  394.     const TQ3Vector2D    *v2);
  395.  
  396. EXPORT float Q3Vector3D_Dot(
  397.     const TQ3Vector3D    *v1, 
  398.     const TQ3Vector3D    *v2);
  399.  
  400.  
  401. /******************************************************************************
  402.  **                                                                             **
  403.  **                        Point and Vector Transformation                         **
  404.  **                                                                             **
  405.  *****************************************************************************/
  406.  
  407. EXPORT TQ3Vector2D *Q3Vector2D_Transform(
  408.     const TQ3Vector2D        *vector2D,
  409.     const TQ3Matrix3x3        *matrix3x3,
  410.     TQ3Vector2D                *result);
  411.     
  412. EXPORT TQ3Vector3D *Q3Vector3D_Transform(
  413.     const TQ3Vector3D        *vector3D,
  414.     const TQ3Matrix4x4        *matrix4x4,
  415.     TQ3Vector3D                *result);
  416.  
  417. EXPORT TQ3Point2D *Q3Point2D_Transform(
  418.     const TQ3Point2D         *point2D,
  419.     const TQ3Matrix3x3        *matrix3x3,
  420.     TQ3Point2D                *result);
  421.  
  422. EXPORT TQ3Param2D *Q3Param2D_Transform(
  423.     const TQ3Param2D         *param2D,
  424.     const TQ3Matrix3x3        *matrix3x3,
  425.     TQ3Param2D                *result);
  426.  
  427. EXPORT TQ3Point3D *Q3Point3D_Transform(
  428.     const TQ3Point3D            *point3D,
  429.     const TQ3Matrix4x4        *matrix4x4,
  430.     TQ3Point3D                *result);
  431.  
  432. EXPORT TQ3RationalPoint4D *Q3RationalPoint4D_Transform(
  433.     const TQ3RationalPoint4D    *point4D, 
  434.     const TQ3Matrix4x4        *matrix4x4,
  435.     TQ3RationalPoint4D        *result);
  436.     
  437. EXPORT TQ3Status Q3Point3D_To3DTransformArray(
  438.     const TQ3Point3D         *inVertex, 
  439.     const TQ3Matrix4x4         *matrix,
  440.     TQ3Point3D                 *outVertex,  
  441.     long                     numVertices, 
  442.     unsigned long             inStructSize, 
  443.     unsigned long             outStructSize);
  444.     
  445. EXPORT TQ3Status Q3Point3D_To4DTransformArray(
  446.     const TQ3Point3D         *inVertex, 
  447.     const TQ3Matrix4x4         *matrix,
  448.     TQ3RationalPoint4D         *outVertex,  
  449.     long                     numVertices,
  450.     unsigned long             inStructSize, 
  451.     unsigned long             outStructSize);
  452.     
  453. EXPORT TQ3Status Q3RationalPoint4D_To4DTransformArray(
  454.     const TQ3RationalPoint4D *inVertex, 
  455.     const TQ3Matrix4x4         *matrix,
  456.     TQ3RationalPoint4D         *outVertex,  
  457.     long                     numVertices, 
  458.     unsigned long             inStructSize, 
  459.     unsigned long             outStructSize);
  460.  
  461.  
  462. /******************************************************************************
  463.  **                                                                             **
  464.  **                                Vector Negation                                 **
  465.  **                                                                             **
  466.  *****************************************************************************/
  467.  
  468. EXPORT TQ3Vector2D *Q3Vector2D_Negate(
  469.     const TQ3Vector2D        *vector2D,
  470.     TQ3Vector2D                *result);
  471.  
  472. EXPORT TQ3Vector3D *Q3Vector3D_Negate(
  473.     const TQ3Vector3D        *vector3D,
  474.     TQ3Vector3D                *result);
  475.  
  476.  
  477. /******************************************************************************
  478.  **                                                                             **
  479.  **                Vector conversion from cartesian to polar                     **
  480.  **                                                                             **
  481.  *****************************************************************************/
  482.  
  483. EXPORT TQ3PolarPoint *Q3Point2D_ToPolar(
  484.     const TQ3Point2D        *point2D,
  485.     TQ3PolarPoint            *result);
  486.     
  487. EXPORT TQ3Point2D *Q3PolarPoint_ToPoint2D(
  488.     const TQ3PolarPoint        *polarPoint,
  489.     TQ3Point2D                *result);
  490.     
  491. EXPORT TQ3SphericalPoint *Q3Point3D_ToSpherical(
  492.     const TQ3Point3D        *point3D,
  493.     TQ3SphericalPoint        *result);
  494.     
  495. EXPORT TQ3Point3D *Q3SphericalPoint_ToPoint3D(
  496.     const TQ3SphericalPoint    *sphericalPoint,
  497.     TQ3Point3D                *result);
  498.  
  499.  
  500. /******************************************************************************
  501.  **                                                                             **
  502.  **                            Point Affine Combinations                         **
  503.  **                                                                             **
  504.  *****************************************************************************/
  505.  
  506. EXPORT TQ3Point2D *Q3Point2D_AffineComb(
  507.     const TQ3Point2D                *points2D,
  508.     const float                    *weights,
  509.     unsigned long                nPoints, 
  510.     TQ3Point2D                    *result);
  511.  
  512. EXPORT TQ3Param2D *Q3Param2D_AffineComb(
  513.     const TQ3Param2D                *param2Ds,
  514.     const float                    *weights,
  515.     unsigned long                nPoints, 
  516.     TQ3Param2D                    *result);
  517.  
  518. EXPORT TQ3RationalPoint3D *Q3RationalPoint3D_AffineComb(
  519.     const TQ3RationalPoint3D        *points3D,
  520.     const float                    *weights,
  521.     unsigned long                nPoints, 
  522.     TQ3RationalPoint3D            *result);
  523.     
  524. EXPORT TQ3Point3D *Q3Point3D_AffineComb(
  525.     const TQ3Point3D                *points3D,
  526.     const float                    *weights,
  527.     unsigned long                nPoints, 
  528.     TQ3Point3D                    *result);
  529.  
  530. EXPORT TQ3RationalPoint4D *Q3RationalPoint4D_AffineComb(
  531.     const TQ3RationalPoint4D        *points4D,
  532.     const float                    *weights,
  533.     unsigned long                nPoints, 
  534.     TQ3RationalPoint4D            *result);
  535.     
  536.     
  537. /******************************************************************************
  538.  **                                                                             **
  539.  **                            Miscellaneous Functions                             **
  540.  **                                                                             **
  541.  *****************************************************************************/
  542.  
  543. #define Q3Math_DegreesToRadians(x)    ((x) *  kQ3Pi / 180.0)
  544. #define Q3Math_RadiansToDegrees(x)    ((x) * 180.0 / kQ3Pi)
  545.  
  546. #define Q3Math_Min(x,y)                ((x) <= (y) ? (x) : (y))
  547. #define Q3Math_Max(x,y)                ((x) >= (y) ? (x) : (y))
  548.  
  549.  
  550. /******************************************************************************
  551.  **                                                                             **
  552.  **                                Matrix Functions                             **
  553.  **                                                                             **
  554.  *****************************************************************************/
  555.  
  556. EXPORT TQ3Matrix3x3 *Q3Matrix3x3_Copy(
  557.     const TQ3Matrix3x3    *matrix3x3,
  558.     TQ3Matrix3x3            *result);
  559.     
  560. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_Copy(
  561.     const TQ3Matrix4x4    *matrix4x4,
  562.     TQ3Matrix4x4            *result);
  563.  
  564.  
  565. EXPORT TQ3Matrix3x3 *Q3Matrix3x3_SetIdentity(
  566.     TQ3Matrix3x3            *matrix3x3);
  567.  
  568. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetIdentity(
  569.     TQ3Matrix4x4            *matrix4x4);
  570.  
  571.  
  572. EXPORT TQ3Matrix3x3 *Q3Matrix3x3_Transpose(
  573.     const TQ3Matrix3x3    *matrix3x3,
  574.     TQ3Matrix3x3            *result);
  575.  
  576. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_Transpose(
  577.     const TQ3Matrix4x4    *matrix4x4,
  578.     TQ3Matrix4x4            *result);
  579.  
  580.  
  581. EXPORT TQ3Matrix3x3 *Q3Matrix3x3_Invert(
  582.     const TQ3Matrix3x3    *matrix3x3,
  583.     TQ3Matrix3x3            *result);
  584.  
  585. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_Invert(
  586.     const TQ3Matrix4x4    *matrix4x4,
  587.     TQ3Matrix4x4            *result);
  588.     
  589.     
  590. EXPORT TQ3Matrix3x3 *Q3Matrix3x3_Adjoint(
  591.     const TQ3Matrix3x3    *matrix3x3,
  592.     TQ3Matrix3x3            *result);
  593.  
  594.  
  595. EXPORT TQ3Matrix3x3 *Q3Matrix3x3_Multiply(
  596.     const TQ3Matrix3x3    *matrixA,
  597.     const TQ3Matrix3x3    *matrixB,
  598.     TQ3Matrix3x3            *result);
  599.  
  600. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_Multiply(
  601.     const TQ3Matrix4x4    *matrixA,
  602.     const TQ3Matrix4x4    *matrixB,
  603.     TQ3Matrix4x4            *result);
  604.  
  605.  
  606. EXPORT TQ3Matrix3x3 *Q3Matrix3x3_SetTranslate(
  607.     TQ3Matrix3x3            *matrix3x3,    
  608.     float                xTrans,
  609.     float                yTrans);
  610.  
  611. EXPORT TQ3Matrix3x3 *Q3Matrix3x3_SetScale(
  612.     TQ3Matrix3x3            *matrix3x3,
  613.     float                xScale,
  614.     float                yScale);
  615.  
  616.  
  617. EXPORT TQ3Matrix3x3 *Q3Matrix3x3_SetRotateAboutPoint(
  618.     TQ3Matrix3x3            *matrix3x3,
  619.     const TQ3Point2D        *origin,
  620.     float                angle);
  621.  
  622. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetTranslate(
  623.     TQ3Matrix4x4        *matrix4x4,
  624.     float            xTrans,
  625.     float            yTrans,
  626.     float            zTrans);
  627.  
  628. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetScale(
  629.     TQ3Matrix4x4        *matrix4x4,
  630.     float            xScale,
  631.     float            yScale,
  632.     float            zScale);
  633.  
  634.  
  635. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotateAboutPoint(
  636.     TQ3Matrix4x4        *matrix4x4,
  637.     const TQ3Point3D    *origin,
  638.     float            xAngle,
  639.     float            yAngle,
  640.     float            zAngle);
  641.     
  642. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotateAboutAxis(
  643.     TQ3Matrix4x4            *matrix4x4,
  644.     const TQ3Point3D        *origin,
  645.     const TQ3Vector3D    *orientation,   
  646.     float                angle);    
  647.     
  648. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotate_X(
  649.     TQ3Matrix4x4        *matrix4x4,
  650.     float            angle);
  651.     
  652. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotate_Y(
  653.     TQ3Matrix4x4        *matrix4x4,
  654.     float            angle);
  655.  
  656. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotate_Z(
  657.     TQ3Matrix4x4        *matrix4x4,
  658.     float            angle);
  659.         
  660. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotate_XYZ(
  661.     TQ3Matrix4x4        *matrix4x4,
  662.     float            xAngle,
  663.     float            yAngle,
  664.     float            zAngle);                            
  665.                             
  666. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetRotateVectorToVector(
  667.     TQ3Matrix4x4            *matrix4x4,
  668.     const TQ3Vector3D    *v1,
  669.     const TQ3Vector3D    *v2);
  670.     
  671.  
  672. EXPORT float Q3Matrix3x3_Determinant(
  673.     const TQ3Matrix3x3    *matrix3x3);
  674.  
  675. EXPORT float Q3Matrix4x4_Determinant(
  676.     const TQ3Matrix4x4    *matrix4x4);
  677.     
  678.     
  679.     
  680. /******************************************************************************
  681.  **                                                                             **
  682.  **                                Quaternion Routines                             **
  683.  **                                                                             **
  684.  *****************************************************************************/
  685.  
  686. EXPORT TQ3Quaternion *Q3Quaternion_Set(
  687.     TQ3Quaternion            *quaternion,
  688.     float                    w,
  689.     float                    x,
  690.     float                    y,
  691.     float                    z);
  692.     
  693. EXPORT TQ3Quaternion *Q3Quaternion_SetIdentity(
  694.     TQ3Quaternion            *quaternion);
  695.     
  696. EXPORT TQ3Quaternion *Q3Quaternion_Copy(
  697.     const TQ3Quaternion        *quaternion, 
  698.     TQ3Quaternion             *result);
  699.  
  700. EXPORT TQ3Boolean Q3Quaternion_IsIdentity(
  701.     const TQ3Quaternion        *quaternion);
  702.  
  703. EXPORT TQ3Quaternion *Q3Quaternion_Invert(
  704.     const TQ3Quaternion         *quaternion,
  705.     TQ3Quaternion            *result);
  706.  
  707. EXPORT TQ3Quaternion *Q3Quaternion_Normalize(
  708.     const TQ3Quaternion        *quaternion,
  709.     TQ3Quaternion            *result);
  710.  
  711. EXPORT float Q3Quaternion_Dot(
  712.     const TQ3Quaternion         *q1, 
  713.     const TQ3Quaternion         *q2);
  714.  
  715. EXPORT TQ3Quaternion *Q3Quaternion_Multiply(
  716.     const TQ3Quaternion        *q1, 
  717.     const TQ3Quaternion        *q2,
  718.     TQ3Quaternion            *result);
  719.  
  720. EXPORT TQ3Quaternion *Q3Quaternion_SetRotateAboutAxis(
  721.     TQ3Quaternion             *quaternion, 
  722.     const TQ3Vector3D         *axis, 
  723.     float                     angle);
  724.     
  725. EXPORT TQ3Quaternion *Q3Quaternion_SetRotateXYZ(
  726.     TQ3Quaternion             *quaternion, 
  727.     float                     xAngle, 
  728.     float                     yAngle, 
  729.     float                     zAngle);
  730.     
  731. EXPORT TQ3Quaternion *Q3Quaternion_SetRotateX(
  732.     TQ3Quaternion             *quaternion, 
  733.     float                     angle);
  734.  
  735. EXPORT TQ3Quaternion *Q3Quaternion_SetRotateY(
  736.     TQ3Quaternion             *quaternion, 
  737.     float                     angle);
  738.  
  739. EXPORT TQ3Quaternion *Q3Quaternion_SetRotateZ(
  740.     TQ3Quaternion             *quaternion, 
  741.     float                     angle);
  742.  
  743. EXPORT TQ3Quaternion *Q3Quaternion_SetMatrix(
  744.     TQ3Quaternion             *quaternion, 
  745.     const TQ3Matrix4x4         *matrix);
  746.  
  747. EXPORT TQ3Quaternion *Q3Quaternion_SetRotateVectorToVector(
  748.     TQ3Quaternion             *quaternion, 
  749.     const TQ3Vector3D         *v1, 
  750.     const TQ3Vector3D         *v2);
  751.  
  752. EXPORT TQ3Matrix4x4 *Q3Matrix4x4_SetQuaternion(
  753.     TQ3Matrix4x4             *matrix, 
  754.     const TQ3Quaternion         *quaternion);
  755.  
  756. EXPORT TQ3Quaternion *Q3Quaternion_MatchReflection(
  757.     const TQ3Quaternion        *q1, 
  758.     const TQ3Quaternion         *q2,
  759.     TQ3Quaternion            *result);
  760.  
  761. EXPORT TQ3Quaternion *Q3Quaternion_InterpolateFast(
  762.     const TQ3Quaternion         *q1, 
  763.     const TQ3Quaternion         *q2, 
  764.     float                     t,
  765.     TQ3Quaternion            *result);
  766.  
  767. EXPORT TQ3Quaternion *Q3Quaternion_InterpolateLinear(
  768.     const TQ3Quaternion         *q1, 
  769.     const TQ3Quaternion         *q2, 
  770.     float                     t,
  771.     TQ3Quaternion             *result);
  772.  
  773. EXPORT TQ3Vector3D *Q3Vector3D_TransformQuaternion(
  774.     const TQ3Vector3D         *vector, 
  775.     const TQ3Quaternion         *quaternion,
  776.     TQ3Vector3D                *result);
  777.  
  778. EXPORT TQ3Point3D *Q3Point3D_TransformQuaternion(
  779.     const TQ3Point3D         *vector, 
  780.     const TQ3Quaternion         *quaternion,
  781.     TQ3Point3D                *result);
  782.  
  783.  
  784. /******************************************************************************
  785.  **                                                                             **
  786.  **                                Volume Routines                                 **
  787.  **                                                                             **
  788.  *****************************************************************************/
  789.  
  790. EXPORT TQ3BoundingBox *Q3BoundingBox_Copy(
  791.     const TQ3BoundingBox     *src, 
  792.     TQ3BoundingBox             *dest);
  793.     
  794. EXPORT TQ3BoundingBox *Q3BoundingBox_Union(
  795.     const TQ3BoundingBox     *v1, 
  796.     const TQ3BoundingBox     *v2,
  797.     TQ3BoundingBox            *result);
  798.     
  799. EXPORT TQ3BoundingBox *Q3BoundingBox_Set(
  800.     TQ3BoundingBox             *bBox,
  801.     const TQ3Point3D         *min, 
  802.     const TQ3Point3D         *max,
  803.     TQ3Boolean                isEmpty);
  804.     
  805.     
  806. EXPORT TQ3BoundingBox *Q3BoundingBox_UnionPoint3D(
  807.     const TQ3BoundingBox     *bBox,
  808.     const TQ3Point3D         *pt3D,
  809.     TQ3BoundingBox            *result);
  810.     
  811. EXPORT TQ3BoundingBox *Q3BoundingBox_UnionRationalPoint4D(
  812.     const TQ3BoundingBox     *bBox,
  813.     const TQ3RationalPoint4D *pt4D, 
  814.     TQ3BoundingBox             *result);
  815.  
  816.     
  817. EXPORT TQ3BoundingBox *Q3BoundingBox_SetFromPoints3D(
  818.     TQ3BoundingBox             *bBox, 
  819.     const TQ3Point3D         *pts, 
  820.     unsigned long             nPts,
  821.     unsigned long            structSize);
  822.     
  823. EXPORT TQ3BoundingBox *Q3BoundingBox_SetFromRationalPoints4D(
  824.     TQ3BoundingBox             *bBox, 
  825.     const TQ3RationalPoint4D *pts, 
  826.     unsigned long             nPts,
  827.     unsigned long            structSize);
  828.  
  829.  
  830. /******************************************************************************
  831.  **                                                                             **
  832.  **                                Sphere Routines                                 **
  833.  **                                                                             **
  834.  *****************************************************************************/
  835.  
  836. EXPORT TQ3BoundingSphere *Q3BoundingSphere_Copy(
  837.     const TQ3BoundingSphere     *src, 
  838.     TQ3BoundingSphere         *dest);
  839.     
  840. EXPORT TQ3BoundingSphere *Q3BoundingSphere_Union(
  841.     const TQ3BoundingSphere     *s1, 
  842.     const TQ3BoundingSphere     *s2,
  843.     TQ3BoundingSphere        *result);
  844.  
  845.     
  846. EXPORT TQ3BoundingSphere *Q3BoundingSphere_Set(
  847.     TQ3BoundingSphere         *bSphere,
  848.     const TQ3Point3D         *origin, 
  849.     float                    radius,
  850.     TQ3Boolean                isEmpty);
  851.     
  852. EXPORT TQ3BoundingSphere *Q3BoundingSphere_UnionPoint3D(
  853.     const TQ3BoundingSphere     *bSphere,
  854.     const TQ3Point3D         *pt3D,
  855.     TQ3BoundingSphere        *result);
  856.     
  857. EXPORT TQ3BoundingSphere *Q3BoundingSphere_UnionRationalPoint4D(
  858.     const TQ3BoundingSphere     *bSphere,
  859.     const TQ3RationalPoint4D *pt4D, 
  860.     TQ3BoundingSphere         *result);
  861.  
  862.     
  863. EXPORT TQ3BoundingSphere *Q3BoundingSphere_SetFromPoints3D(
  864.     TQ3BoundingSphere         *bSphere, 
  865.     const TQ3Point3D         *pts, 
  866.     unsigned long             nPts,
  867.     unsigned long            structSize);
  868.     
  869. EXPORT TQ3BoundingSphere *Q3BoundingSphere_SetFromRationalPoints4D(
  870.     TQ3BoundingSphere         *bSphere, 
  871.     const TQ3RationalPoint4D *pts, 
  872.     unsigned long             nPts,
  873.     unsigned long            structSize);    
  874.  
  875. #ifdef __cplusplus
  876. }
  877. #endif    /* __cplusplus */
  878.  
  879. #endif  /*  QD3DMath_h  */
  880.